package com.study.forumsystemproject.dao;

import org.apache.ibatis.annotations.*;

/**
 * program: forum-system-project
 * <p>
 * description:
 * <p>
 * author: xiaoxie
 * <p>
 * create: 2024-08-18 21:39
 **/
@Mapper
public interface UpvoteMapper {
    @Insert("insert into t_upvote(articleId, userId) values(#{articleId}, #{userId})")
    int insert(@Param("userId") Long userId, @Param("articleId") Long articleId);
    @Select("select isUpvote from t_upvote where userId = #{userId} and articleId = #{articleId}")
    Integer selectByArticleIdAndUserId(@Param("userId") Long userId, @Param("articleId") Long articleId);
    @Select("select id from t_upvote where userId = #{userId} and articleId = #{articleId}")
    int selectIdByArticleIdAndUserId(@Param("userId") Long userId, @Param("articleId") Long articleId);
    @Update("update t_upvote set isUpvote = #{isUpvote} where userId = #{userId} and articleId = #{articleId}")
    int updateByArticleIdAndUserId(@Param("isUpvote") Integer isUpvote,@Param("userId") Long userId, @Param("articleId") Long articleId);
}
